class Node {
  constructor(element) {
    this.element = element
    this.next= null
    this.pre = null 
  }  
}

class Linklist {

  constructor(element) {
    this.head = new Node(element)
  }
  
  find(element) {
    let currNode = this.head

    while(currNode.element != element) {
      currNode = currNode.next  
    }   
    
    return currNode
  }
  
  insert(element, item) {
    const node = new Node(element)
    const current = this.find(item)
   
    if(!current) return console.log('无当前元素') 
    current.next = node  
  }
  
  remove(element) {
    let current = this.findPre(element)
    if(!current) return console.log('无当前元素')
  }

  findPre(element) {
    let current = this.head
    while(current.next && current.next.element !== element) {
      return 
    }
  }

  display() {
    let currNode = this.head
    while(!(currNode.next == null)) {
      console.log(currNode.next.element)
      currNode = currNode.next  
    }
  }  
}

const linklist = new Linklist(12)

//console.log(linklist)

linklist.insert(11, 12)
linklist.insert(10, 11)

linklist.display()
